Skip to content

Test the content type guessing and unconvertible responses of AbstractApi - #593

Merged
Art4 merged 1 commit into
v3.xfrom
591-coverage-abstract-api
Nov 26, 2026
Merged

Art4 merged 1 commit into
v3.xfrom
591-coverage-abstract-api

Conversation

@Art4

@Art4 Art4 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

 tests/Unit/Api/AbstractApi/RetrieveDataTest.php
+├── testRetrieveDataSendsContentTypeGuessedFromPath          # json / json with query / xml / upload json + xml / other path
+└── testRetrieveDataAndNotConvertibleResponseThrowsException # unsupported content type / JSON scalar

Tests only, no change in src/. Part 2 of 3 of #591: AbstractApi has no uncovered line left. No changelog entry.

The ticket asked whether getContentTypeFromPath() has unreachable branches. It has none: retrieveData() is protected, so a custom API class extending AbstractApi can call it with any path. Nothing is removed.

Part of #591

Evidence

  • Before: uncovered lines AbstractApi.php 192, 205, 216.
    After: the file is fully covered. Remaining on v3.x: XmlSerializer.php 107, 108 (part 3).
  • QA on PHP 8.2: PHPUnit OK (868 tests, 4400 assertions), PHPStan [OK] No errors, code style 0 files to fix, Rector dry run exit 0. Behat not run locally, no production code changed.

Merge Danger

Door: two-way

Blast Radius: none, tests only.

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for request content-type handling across different paths, including paths with query strings and uploads.
    • Added checks for errors when responses use unsupported content types or contain JSON values that cannot be converted. These tests help verify consistent handling of request formats and invalid responses.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The RetrieveDataTest suite adds cases for request content types inferred from paths and for responses that raise SerializerException during conversion.

Changes: RetrieveData test coverage

Layer / File(s) Summary
Request and response conversion tests
tests/Unit/Api/AbstractApi/RetrieveDataTest.php
Tests check expected request content types for JSON, XML, query, upload, and unrecognized paths. Other cases expect SerializerException for an unsupported response content type and a JSON scalar response.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Possibly related issues

  • Issue 591: This PR adds AbstractApi tests described as part 2 of the issue, but does not cover its other listed components.

Suggested reviewers: kbsali

Merge Risk: Minimal · up to b66c3

This pull request adds test coverage for content-type guessing and unconvertible responses in the API layer. It does not change runtime behavior, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two areas the PR tests in AbstractApi: content-type guessing from paths and unconvertible responses. The raw summary shows test-only additions to RetrieveDataTest.php that cover ex…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two areas the PR tests in AbstractApi: content-type guessing from paths and unconvertible responses. The raw summary shows test-only additions to RetrieveDataTest.php that cover exactly these behaviours (path-based content-type expectations, including queries and uploads, and SerializerException for unsupported content types and JSON scalars). The PR objectives match this scope. The title is specific, concise, and describes the main change, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c5d7d04-9654-4a5a-8bb4-f0860c925fad
Commits

Reviewing files that changed from the base of the PR and between a19b6dc and b66c30b.

Files selected for processing: 1

  • tests/Unit/Api/AbstractApi/RetrieveDataTest.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.86%. Comparing base (a19b6dc) to head (b66c30b).

Additional details and impacted files
@@             Coverage Diff              @@
##               v3.x     #593      +/-   ##
============================================
+ Coverage     99.66%   99.86%   +0.19%     
  Complexity      456      456              
============================================
  Files            31       31              
  Lines          1505     1505              
============================================
+ Hits           1500     1503       +3     
+ Misses            5        2       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Art4
Art4 marked this pull request as ready for review November 26, 2026 20:30
@Art4
Art4 merged commit 9de45b7 into v3.x Nov 26, 2026
19 checks passed
@Art4
Art4 deleted the 591-coverage-abstract-api branch November 26, 2026 20:37
@Art4 Art4 added this to the v3.1.0 milestone Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant